#ifndef SM3_H
#define SM3_H

#include "common_func.h"
#include <stdint.h>

#define SM3_BASEADDR 			0xbf100100

#define SM3_MSG_INPT_D 			 SM3_BASEADDR
#define SM3_MSG_INPT_VLD_BYTE 	(SM3_BASEADDR + 0x04)
#define SM3_MSG_INPT_VLD	 	(SM3_BASEADDR + 0x08)
#define SM3_MSG_INPT_LST	 	(SM3_BASEADDR + 0x0c)
#define SM3_MSG_INPT_RDY	 	(SM3_BASEADDR + 0x10)
#define SM3_CMPRSS_OTPT_RES_0 	(SM3_BASEADDR + 0x14)
#define SM3_CMPRSS_OTPT_RES_1 	(SM3_BASEADDR + 0x18)
#define SM3_CMPRSS_OTPT_RES_2 	(SM3_BASEADDR + 0x1c)
#define SM3_CMPRSS_OTPT_RES_3 	(SM3_BASEADDR + 0x20)
#define SM3_CMPRSS_OTPT_RES_4 	(SM3_BASEADDR + 0x24)
#define SM3_CMPRSS_OTPT_RES_5 	(SM3_BASEADDR + 0x28)
#define SM3_CMPRSS_OTPT_RES_6 	(SM3_BASEADDR + 0x2c)
#define SM3_CMPRSS_OTPT_RES_7 	(SM3_BASEADDR + 0x30)
#define SM3_CMPRSS_OTPT_VLD		(SM3_BASEADDR + 0x34)
#define SM3_ENABLE_INT			(SM3_BASEADDR + 0x38)

#define SM3_WAIT_TIME		0x01


typedef struct SM3_Handle_
{
	uint32_t data;
	uint8_t init_flag;
	uint8_t update_flag;
	uint8_t first_data_flag;
} SM3_Handle_t;

uint32_t sm3_init(SM3_Handle_t *session_handle);
uint32_t sm3_update(SM3_Handle_t *session_handle, uint32_t data);
uint32_t sm3_final(SM3_Handle_t *session_handle, uint32_t *result_data);
uint32_t sm3_callback(uint32_t *result_data);
uint32_t sm3_final_int(SM3_Handle_t *session_handle);

#endif 
